import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    // 用户名
    username: '',
    cartCount: 0
  },
  mutations: {
    setUserName (state, username) {
      state.username = username
    },
    setCartCount (state, count) {
      state.cartCount = count
    }
  },
  actions: {
    setUserName (context, username) {
      context.commit('setUserName', username)
    },
    setCartCount ({ commit }, count) {
      commit('setCartCount', count)
    }
  },
  modules: {
  }
})
